package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.business.domain.ElderHealthCheckup;
import com.elder.business.service.IElderHealthCheckupService;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 老人健康体检Controller
 * 
 * @author zyk
 * @date 2023-11-26
 */
@RestController
@RequestMapping("/business/checkupInfo")
public class ElderHealthCheckupController extends BaseController
{
    @Autowired
    private IElderHealthCheckupService elderHealthCheckupService;

    /**
     * 查询老人健康体检列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(String elderName ,String startTime ,String endTime ,Integer pageNum ,Integer pageSize)
    {
        return elderHealthCheckupService.selectElderHealthCheckupList(elderName,startTime,endTime,pageNum,pageSize);
    }

    /**
     * 获取老人健康体检详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(elderHealthCheckupService.selectElderHealthCheckupById(id));
    }

    /**
     * 新增老人健康体检
     */
    @Anonymous
    @Log(title = "老人健康体检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElderHealthCheckup elderHealthCheckup)
    {
        return toAjax(elderHealthCheckupService.insertElderHealthCheckup(elderHealthCheckup));
    }

    /**
     * 修改老人健康体检
     */
    @Anonymous
    @Log(title = "老人健康体检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElderHealthCheckup elderHealthCheckup)
    {
        return toAjax(elderHealthCheckupService.updateElderHealthCheckup(elderHealthCheckup));
    }

    /**
     * 删除老人健康体检
     */
    @PreAuthorize("@ss.hasPermi('business:checkupInfo:remove')")
    @Log(title = "老人健康体检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(elderHealthCheckupService.deleteElderHealthCheckupByIds(ids));
    }
}
